﻿package frEngine.primitives
{
    import baseEngine.basic.*;
    import baseEngine.core.*;
    import baseEngine.materials.*;
    import frEngine.core.*;
    import frEngine.loaders.particleSub.particleInstance.*;
    import frEngine.shader.filters.*;

    public class FrSphere extends Mesh3D
    {
        private var _radius:Number;
        private var _segments:int;
        private var _surf:FrSurface3D;

        public function FrSphere(param1:String)
        {
            super(param1, false, null);
            this._surf = new FrSurface3D(param1 + "_surface");
            this._surf.addVertexData(FilterName_ID.POSITION_ID, 3, false, null);
            this._surf.addVertexData(FilterName_ID.UV_ID, 2, false, null);
            this._surf.addVertexData(FilterName_ID.NORMAL_ID, 3, false, null);
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            super.dispose(param1);
            this._surf.download();
            return;
        }// end function

        public function reinit(param1:RenderList, param2:Number = 5, param3:int = 24, param4:Material3D = null) : void
        {
            this.renderList = param1;
            this._segments = param3;
            this._radius = param2;
            this.addSurface(this._surf);
            var _loc_5:* = new SphereData(this._radius, param3);
            this._surf.getVertexBufferByNameId(FilterName_ID.POSITION_ID).vertexVector = _loc_5.vertexVector;
            this._surf.indexVector = _loc_5.indexVector;
            bounds = new Boundings3D();
            bounds.max.setTo(param2, param2, param2);
            bounds.min.setTo(-param2, -param2, -param2);
            bounds.length = bounds.max.subtract(bounds.min);
            bounds.radius = param2 * 2;
            return;
        }// end function

        public function get radius() : Number
        {
            return this._radius;
        }// end function

        public function get segments() : int
        {
            return this._segments;
        }// end function

    }
}
